package java实验五;
import java.util.Scanner;
public class 程序四 {
	
	public static void main(String [] args)
	{
		Scanner input =new Scanner (System.in);
		
		
		System.out.println("输入数组的个数");
		int  n = input.nextInt();
		double []a=new double[n];
		System.out.println("输入要数组中的数");
		for(int i=0;i<a.length;i++)
		{
			a[i]=input.nextDouble();
		}
		
		System.out.println("输入要查找的数");
		double key =input.nextDouble();
		
		int wkey =li(a,key);
		System.out.println("查找的数在第"+wkey+"位");
		System.out.println("对数组进行排序，排序后为");
		se(a);
		for(int i = 0;i<a.length;i++)
			System.out.println(a[i]);
		input.close();
		
	}
	public static int li (double []list,double key)
	{
		for(int i=0;i<=list.length;i++)
		{
			if(key==list[i])
				return i;
			
		}
		return -1;
		
	}
	public static void se(double []list)
	{
		for(int i=0;i<list.length-1;i++)
		{
			double c=list[i];
			int cc=i;
			for(int j=i+1;j<list.length;j++)
			{
				if(c>list[j])
				{
					c=list[j];
					cc=j;
				}
				
			}
			if(cc!=i)
		{
			list[cc]=list[i];
			list[i]=c;
		}
		}
	}
}
